import "pkl:test"

example1 {
  local f = (x) -> new Dynamic {}
  result = (f) { x: Int -> prop = x + 1 }.apply(1)
}

example2 {
  local f = (x, y) -> new Dynamic {}
  result = (f) { a, b: Number -> prop = a + b }.apply(1, 2)
}

example3 {
  local f = (x, y) -> new Dynamic {}
  result = test.catch(() -> (f) { a, b: Number(this > 3) -> prop = a + b }.apply(1, 2))
}

example4 {
  local f = (x, y) -> (z) -> new Dynamic { prop3 = z }
  result = test.catch(() -> (f) { a: String, b -> prop1 = a; prop2 = b }.apply(1, 2).apply(3))
}

class Foo
class Bar
class Baz

example5 {
  local f = (x, y, z) -> new Dynamic { prop3 = z }
  result = (f) { a: Foo, b: Bar, c: Baz -> prop1 = a; prop2 = b }.apply(new Foo {}, new Bar {}, new Baz {})
}

example6 {
  local f = (x, y, z) -> new Dynamic { prop3 = z }
  result = test.catch(() -> (f) { a: Baz, b: Bar, c: Foo -> prop1 = a; prop2 = b }.apply(new Foo {}, new Bar {}, new Baz {}))
}
